<template>
	<view>
		<view class="dangan">
			<view class="f14 flex-cen" style="color: #FF4800;background-color: #FFDFD2;
			height: 64rpx;">
				请认真填写相关信息
			</view>
			<view class="dangan-yi" v-if="false">
				<view class="dangan-yi-left">
					病例编号：
				</view>
				<view class="dangan-yi-right">
					<input type="text" class=" h100" v-model="form.id">
				</view>
			</view>
			<view class="line"></view>
			<view class="dangan-yi">
				<view class="dangan-yi-left">
					姓名：
				</view>
				<view class="dangan-yi-right">
					<input type="text" class=" h100" v-model="form.xtName">
				</view>
			</view>

			<view class="line"></view>
			<view class="dangan-er">
				<!-- <view class="dangan-yi-left">
					<view class="">
						性别：
					</view>
					<u-radio-group v-model="form.xtGender" iconPlacement="right">
						<u-radio activeColor="" label="男" :name="'1'"></u-radio>
						<u-radio activeColor="" label="女" :name="'2'"></u-radio>
					</u-radio-group>
				</view> -->
				
<!-- 				<view class="dangan-yi-left">
					<view class="">
						血型：
					</view>
					<input type="text" class=" h100" v-model="form.bloodType">
				</view> -->

				<view class="dangan-yi-right">
					<view class="">
						年龄：
					</view>
					<input type="number" class=" h100" v-model="form.xtAge">
				</view>
			</view>
			<view class="line"></view>
			<!-- <view class="dangan-yi">
				<view class="dangan-yi-left">
					手机号：
				</view>
				<view class="dangan-yi-right">
					<input type="text" class=" h100" v-model="form.xtPhone">
				</view>
			</view> -->
			<!-- <view class="line"></view> -->
			<!-- 	<view class="dangan-yi">
				<view class="dangan-yi-left">
					身份证：
				</view>
				<view class="dangan-yi-right">
					<input type="text" class=" h100" v-model="form.xtIdNumber">
				</view>
			</view> -->
			<!-- <view class="line"></view> -->

			<!-- <view class="line"></view> -->
			<view class="dangan-er">
				<view class="dangan-yi-left">
					<view class="">
						体重：
					</view>
					<input placeholder="kg" type="number" class=" h100" v-model="form.weight">
				</view>
				<view class="dangan-yi-right">
					<view class="">
						身高：
					</view>
					<input placeholder="cm" type="number" class=" h100" v-model="form.height"> 
				</view>
			</view>

			<view class="line"></view>

			<view class="dangan-san">
				<view class="dangan-san-hd">
					患者病史：
				</view>
				<view class="dangan-san-db">
					<textarea name="text" cols="40" rows="10" v-model="form.medicalHistory"></textarea>
				</view>
			</view>
			<view class="line"></view>
			<view class="dangan-san">
				<view class="dangan-san-hd">
					患者过敏病史:
				</view>
				<view class="dangan-san-db">
					<textarea name="text" cols="40" rows="10" v-model="form.allergicHistory"></textarea>
				</view>
			</view>
			<view class="di  main">
				<button class="btn  btn-big" @click="getAdd()" hover-class="btn-hor">确认</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {},
			};
		},
		onLoad() {
			// this.getList()
		},
		onShow() {
			this.getFiles()
		},
		methods: {
			async getFiles() {
				let re = await this.$API.familyApi.getUserInfo()
				console.log(re, "getFiles");
				if (re) {
					this.form = re
				}
			},
			async getAdd() {
				console.log(this.form, "form");
				
				
				let {
					xtName,
					xtAge,
					height,
					weight,
				} = this.form;
				console.log(this.form)
				if (xtName == '' || xtName == undefined || xtName == null) {
					uni.showToast({
						icon: 'none',
						title: "姓名不能为空",
					});
					return;
				}
				
				// if (!xtIdVerification(xtIdNumber)) {
				// 	uni.showToast({
				// 		icon: 'none',
				// 		title: '请输入正确的身份证号码'
				// 	})
				// 	return
				// }
				// if (!telVerification(xtPhone)) {
				// 	uni.showToast({
				// 		icon: 'none',
				// 		title: '请输入正确的11位手机号'
				// 	})
				// 	return
				// }
				if (xtAge == '' || xtAge == undefined || xtAge == null) {
					uni.showToast({
						icon: 'none',
						title: "年龄不能为空",
					});
					return
				}
				if (height == '' || height == undefined || height == null) {
					uni.showToast({
						icon: 'none',
						title: "身高不能为空",
					});
					return
				}
				if (weight == '' || weight == undefined || weight == null) {
					uni.showToast({
						icon: 'none',
						title: "体重不能为空",
					});
					return
				}

				
				
				let re = await this.$API.filesApi.setFiles(this.form)
				if (re) {
					uni.showToast({
						title: '修改成功'
					})
					uni.switchTab({
						url: '/pages/home/home'
					})
					return
				}
			},
		}
	}
</script>

<style lang="less">
	.dangan {
		.dangan-yi {
			padding: 0 40rpx;
			line-height: 100rpx;
			display: flex;
			font-size: 29rpx;
			letter-spacing: 5rpx;

			// justify-content: space-evenly;
			.dangan-yi-left {
				// text-align: center;
				// width: 160rpx;
				padding-right: 30rpx;
			}

			.dangan-yi-right {
				width: 430rpx;
			}
		}

		.dangan-er {
			padding: 0 40rpx;
			line-height: 100rpx;
			// display: flex;
			font-size: 30rpx;
			display: flex;
			letter-spacing: 5rpx;
			box-sizing: border-box;

			.dangan-yi-left {
				width: 50%;
				display: flex;
				// background-color: red;
				align-items: center;

				input {
					width: 230rpx;
				}
			}

			.dangan-yi-right {
				width: 50%;
				display: flex;
				// background-color: red;
				align-items: center;

				input {
					width: 230rpx;
				}
			}
		}

		.dangan-san {
			padding: 20rpx 40rpx;
			font-size: 30rpx;
			letter-spacing: 5rpx;

			.dangan-san-db {
				margin-top: 20rpx;
			}
		}
	}
</style>